<script setup lang="ts">
import { PropType } from 'vue'
import type { TableData } from '@/api/role/types'
import { Descriptions } from '@/components/Descriptions'

// 获取字典
import { useCache } from '@/hooks/web/useCache'
const { wsCache } = useCache()
const dict: any = wsCache.get('dict')
// 字典通过value获取label
const getDictLabel = (type, value) => {
  let data = dict[type].find((item) => {
    return item.value == value
  })
  return data ? data.label : ''
}

defineProps({
  currentRow: {
    type: Object as PropType<Nullable<TableData>>,
    default: () => null
  },
  detailSchema: {
    type: Array as PropType<DescriptionsSchema[]>,
    default: () => []
  }
})
</script>

<template>
  <Descriptions :schema="detailSchema" :data="currentRow || {}">
    <template #type="{ row }: { row: any }">
      <div>{{ getDictLabel('logistics_type', row.type) }}</div>
    </template>
  </Descriptions>
</template>
